< previous page page_165 next page >

Page 165
#define IDI_APPLICATION     MAKEINTRESOURCE(32512)
#define IDI_HAND            MAKEINTRESOURCE(32513)
#define IDI_QUESTION        MAKEINTRESOURCE(32514)
#define IDI_EXCLAMATION     MAKEINTRESOURCE(32515)
#define IDI_ASTERISK        MAKEINTRESOURCE(32516)
#if(WINVER >= 0x0400)
#define IDI_WINLOGO         MAKEINTRESOURCE(32517)
#endif /* WINVER >= 0x0400 */
The IDI_WINLOGO constant describes a constant that only exists on Windows 95 and later and Windows NT and later, so we can include it.
What does the term MAKEINTRESOURCE refer to? MAKEINTRESOURCE is a precompiler macro. A macro is like a function, except that it is processed during the compilation process by the compiler. The result of the macro is text that is actually compiled. Now all we need to do is take a closer look at the MAKEINTRESOURCE macro:
#define MAKEINTRESOURCEA(i) (LPSTR)((DWORD)((WORD)(i)))
#define MAKEINTRESOURCEW(i) (LPWSTR)((DWORD)((WORD)(i)))
#ifdef UNICODE
#define MAKEINTRESOURCE  MAKEINTRESOURCEW
#else
#define MAKEINTRESOURCE  MAKEINTRESOURCEA
#endif // !UNICODE
We're creating an ANSI program, so the UNICODE condition does not matter to us. The MAKEINTRESOURCE macro definition reduces to the following:
#define MAKEINTRESOURCEA(i) (LPSTR)((DWORD)((WORD)(i)))
#define MAKEINTRESOURCE  MAKEINTRESOURCEA
What does this mean?
Consider what happens when you include the term IDI_WINLOGO in your program.
The term IDI_WINLOGO is replaced by MAKEINTRESOURCE(32517).
MAKEINTRESOURCE(32517) is replaced by MAKEINTRESOURCEA(32517).
MAKEINTRESOURCEA(32517) is replaced by (LPSTR) ((DWORD) ((WORD) 32517))).
The term (LPSTR)((DWORD) ((WORD)32517))) is finally compiled by the compiler.
This term is potentially confusing as well. Consider first the term ((WORD)32517). What does this mean?

 
< previous page page_165 next page >